class BgcContentSave {
  final String aid;
  final String title;
  final String content;
  final String richContent;
  final List<String> images;
  final String? videos;
  final String? thumbnail;
  final List<TaskTagBo> taskTagBoList;
  final int? taskConfigId;
  final int? taskRecordId;
  final int? id;

  BgcContentSave({
    required this.aid,
    required this.title,
    required this.content,
    required this.richContent,
    required this.images,
    this.videos,
    this.thumbnail,
    required this.taskTagBoList,
    this.taskConfigId,
    this.taskRecordId,
    this.id,
  });

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = {
      'aid': aid,
      'title': title,
      'content': content,
      'richContent': richContent,
      'images': images,
      'taskTagBoList': taskTagBoList.map((tag) => tag.toJson()).toList(),
    };

    if (videos != null) json['videos'] = videos;
    if (thumbnail != null) json['thumbnail'] = thumbnail;
    if (taskConfigId != null) json['taskConfigId'] = taskConfigId;
    if (taskRecordId != null) json['taskRecordId'] = taskRecordId;
    if (id != null) json['id'] = id;

    return json;
  }

  factory BgcContentSave.fromJson(Map<String, dynamic> json) {
    return BgcContentSave(
      aid: json['aid'],
      title: json['title'],
      content: json['content'],
      richContent: json['richContent'],
      images: List<String>.from(json['images']),
      videos: json['videos'],
      thumbnail: json['thumbnail'],
      taskTagBoList: List<TaskTagBo>.from(
          json['taskTagBoList'].map((x) => TaskTagBo.fromJson(x))),
      taskConfigId: json['taskConfigId'],
      taskRecordId: json['taskRecordId'],
      id: json['id'],
    );
  }
}

class TaskTagBo {
  final int? id;
  final String? name;
  final String? type; // FIXED 或 CUSTOM

  TaskTagBo({
    this.id,
    this.name,
    this.type,
  });

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'type': type,
    };
  }

  factory TaskTagBo.fromJson(Map<String, dynamic> json) {
    return TaskTagBo(
      id: json['id'],
      name: json['name'],
      type: json['type'],
    );
  }
}
